<template>
  <div class="">
    <div class="page-filter mb10 fl">
      <el-form ref="filter" :model="filter" label-width="0">
        <el-form-item class="mr10 mb5 fl">
          <el-input v-model="filter.name" placeholder="品名" size="small" clearable />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" style="width: 300px">
          <el-button size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
          <el-button type="primary" size="small" @click="getList">查 询</el-button>
          <el-button type="primary" size="small" @click="handleDialog({dTitle: '新增采购订单', dType: 'add', dField: dField})">新 增</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table v-loading="app.loading" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="项目名称" width="260px" prop="pro_name" />
      <el-table-column label="合同编号" width="190px" prop="sn">
        <template slot-scope="{row}">
          {{ "LOPO" + row.sn }}
        </template>
      </el-table-column>
      <el-table-column label="货物明细" align="center" width="90px" prop="sn">
        <template slot-scope="{row}">
          <a
            href="javascript:void(0)"
            @click="handleDialog({...row, ...
            {dTitle: '出库详情', dType: 'view', dField: dField}})"
          >详情</a>
        </template>
      </el-table-column>
      <el-table-column label="金额" width="110px" align="right" prop="price" />
      <el-table-column label="状态" align="center" width="80px" :formatter="fState" />
      <el-table-column label="采购日期" width="110px" align="center" prop="pur_time" />
      <el-table-column label="申请时间" align="center" width="140px" prop="apply_time" />
      <el-table-column label="备注" min-width="260px" prop="remark" />
      <el-table-column label="操作" align="center" width="90px" fixed="right">
        <template slot-scope="{row}">
          <el-dropdown>
            <el-button type="primary" size="mini">
              操作<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                @click.native="handleDialog({...row, ...
                {dTitle: '出货明细', dType: 'view', dField: dField}})"
              >详 情</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
    <Dialog ref="dialog" :get-data="getList" :info="dialog" />
  </div>
</template>

<script>
import { purs } from '@/api/purchase'
import Dialog from './components/inventoryex-dialog'
import page from '@/utils/page'

export default {
  components: { Dialog },
  extends: page,
  props: {
    reqList: {
      default: purs,
      type: Function
    }
  },
  data() {
    return {
      parameter: { type: '4' },
      dField: ['id', 'pro_id', 'remark']
    }
  },
  created() {
    this.getList()
  },
  methods: {
    fState(e) {
      let v = '未采购'
      if (e.state === 1) v = '已采购'
      return v
    }
  }
}
</script>
